<?php
/**
 * Created by PhpStorm.
 * User: luiz
 * Date: 2019/5/8
 * Time: 17:41
 */

namespace app\api\controller\v1;


use app\api\controller\BaseConitroller;
use app\api\service\Token as TokenService;
use app\api\service\UserToken;
use app\api\validate\TokenGet;
use app\lib\exception\ParameterException;


class Token extends BaseConitroller
{
    public function getToken($code='')
    {
        (new TokenGet())->goCheck();
        $ut = new UserToken($code);
        $token = $ut->get();
        $a = [
          'token'=>$token
        ];
        return json($a);
    }
    public function verifyToken($token='')
    {
        if(!$token){
            throw new ParameterException([
                'token不允许为空'
            ]);
        }
        $valid = TokenService::verifyToken($token);
        return  json([
            'isValid' => $valid
        ]);
    }
}